package com.service.impl;

import com.entity.Checkinfo;
import com.entity.Stores;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mapper.CheckinfoMapper;
import com.service.CheckinfoService;
import com.vo.Page;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author :hcy
 * @date:
 * @description:
 */
@Service
public class CheckinfoServiceImpl implements CheckinfoService {
    @Resource
    private CheckinfoMapper checkinfoMapper;
    @Override
    public PageInfo<Checkinfo> listAllCheckinfo(Page<Checkinfo> page) {
        PageHelper.startPage(page.getPageNum(),page.getPageSize());
        List<Checkinfo> checkinfos = checkinfoMapper.listAllCheckinfo(page.getData());
        for (Checkinfo checkinfo : checkinfos) {
            if (checkinfo.getState().equals(0)){
                checkinfo.setStates("待审核");
            }else if (checkinfo.getState().equals(1)){
                checkinfo.setStates("已通过");
            }else if (checkinfo.getState().equals(2)){
                checkinfo.setStates("未通过");
            }
        }
        PageInfo<Checkinfo> checkinfoPageInfo = new PageInfo<>(checkinfos);
        return checkinfoPageInfo;
    }

    @Override
    public Checkinfo getById(Integer checkId) {
        return checkinfoMapper.getById(checkId);
    }

    @Override
    public int addinfoCheckinfo(Checkinfo checkinfo) {
        return checkinfoMapper.addinfoCheckinfo(checkinfo);
    }

    @Override
    public int deleteCheckinfo(Integer checkId) {
        return checkinfoMapper.deleteCheckinfo(checkId);
    }

    @Override
    public List<Stores> listStores() {
        return checkinfoMapper.listStores();
    }

    @Override
    public int updateState(Checkinfo haha) {
        return checkinfoMapper.updateState(haha);
    }
}
